<!DOCTYPE html>
<html xmlns:ng="http://angularjs.org">
  <!--
    Copyright 2011, Google Inc. All Rights Reserved.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

    author: api.ekoleda@gmail.com (Eric Koleda)
  -->
  <head>
    <title>AdWords API Sample Web Application</title>
    <link rel="stylesheet" href="css/main.css" />
    <script type="text/javascript" src="js/angular-0.9.7.min.js" ng:autobind>
    </script>
    <script src="http://www.google.com/jsapi"></script>
    <script type="text/javascript">
      // Load jQuery library.
      google.load('jquery', '1.3.2');
    </script>
    <script type="text/javascript" src="js/jquery.cookie.js"></script>
    <script type="text/javascript" src="js/main.js"></script>
  </head>
  <body ng:controller="PageController">
    <h1>AdWords API Sample Web Application</h1>

    <div id="error" ng:show="error">
      An error has occurred: {{error}}
    </div>

    <div id="login" class="hidden">
      <input type="button" name="login" value="Login"
        onclick="window.location='login.php';" />
      <strong>Not authenticated.</strong>
    </div>
    <div id="logout" class="hidden">
      <input type="button" name="logout" value="Logout"
          onclick="window.location='logout.php';" />
      <strong>
        Authenticated via OAuth.
        <span ng:show="rootAccount">Logged in as: {{rootAccount.login}}</span>
      </strong>
    </div>

    <div id="accounts">
      <label for="customerId">Accounts: </label>
      <span ng:show="!accounts && !accountsLoading">No accounts.</span>
      <span ng:show="accountsLoading">Loading ...</span>
      <select name="customerId" ng:show="accounts">
        <option ng:repeat="account in accounts"
            value="{{account.customerId}}">{{account.login}}</option>
      </select>
    </div>

    <div id="container" class="column-container">
      <div id="campaigns-column" class="column">
        <h2>Campaigns</h2>
        <label for="status">Status: </label>
        <select name="status">
          <option>ACTIVE</option>
          <option>PAUSED</option>
          <option>DELETED</option>
        </select>
        <input type="button" name="refresh" value="Refresh"
            ng:click="loadCampaigns(true)" />
        <div class="column-content">
          <div ng:show="!campaigns && !campaignsLoading">No campaigns.</div>
          <div ng:show="campaignsLoading">Loading...</div>
          <ul ng:show="campaigns"
              ng:watch="customerId:loadCampaigns(); status:loadCampaigns()">
            <li ng:repeat="campaign in campaigns">
              <a href="#" ng:click="showCampaign(campaign)">
                {{campaign.name}}
              </a>
            </li>
          </ul>
        </div>
      </div>

      <div id="selected-campaign-column" class="column">
        <h2>Details</h2>
        <div class="column-content">
          <span ng:show="!selectedCampaign">
            Click on a campaign to view its details.
          </span>
          <div ng:show="selectedCampaign">
            <div>
              <strong>Name</strong>:
              {{selectedCampaign.name}}
            </div>
            <div>
              <strong>ID</strong>:
              {{selectedCampaign.id}}
            </div>
            <div>
              <strong>User status</strong>:
              {{selectedCampaign.status}}
            </div>
            <div>
              <strong>Serving status</strong>:
              {{selectedCampaign.servingStatus}}
            </div>
            <div>
              <strong>Start date</strong>:
              {{selectedCampaign.startDate}}
            </div>
            <div>
              <strong>End date</strong>:
              {{selectedCampaign.endDate}}
            </div>
            <div>
              <strong>Budget</strong>:
              {{selectedCampaign.budget.amount.microAmount}}
            </div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>
